#pragma once

namespace SevenZip
{

enum AskMode
{
	AskModeExtract = 0,
    AskModeTest,
    AskModeSkip
};

enum OperationResult
{
	ResultOK = 0,
	ResultUnsupportedMethod,
	ResultDataError,
	ResultCrcError
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000300020000")
ISequentialOutStream : IUnknown
{
	virtual HRESULT STDMETHODCALLTYPE Write(__in LPCVOID, UINT32, __out PUINT32) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000300010000")
ISequentialInStream : IUnknown
{
	virtual HRESULT STDMETHODCALLTYPE Read(__out_bcount_part(Count, *Read) PVOID, 
	                                                  UINT32 Count, 
	                                            __out PUINT32 Read) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000300030000")
IInStream : ISequentialInStream
{
	virtual HRESULT STDMETHODCALLTYPE Seek(INT64, UINT32, __out PUINT64) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050000")
IProgress : IUnknown
{
	virtual HRESULT STDMETHODCALLTYPE SetTotal(UINT64) PURE;
    virtual HRESULT STDMETHODCALLTYPE SetCompleted(__in UINT64) PURE;
};

MIDL_INTERFACE("23170F69-40C1-278A-0000-000600200000")
IArchiveExtractCallback : IProgress
{
    // GetStream OUT: S_OK - OK, S_FALSE - skip this file
    virtual HRESULT STDMETHODCALLTYPE GetStream(UINT32, __deref_out ISequentialOutStream **, AskMode) PURE;
    virtual HRESULT STDMETHODCALLTYPE PrepareOperation(AskMode) PURE;
    virtual HRESULT STDMETHODCALLTYPE SetOperationResult(OperationResult) PURE;
};

typedef void* IArchiveOpenCallback;

MIDL_INTERFACE("23170F69-40C1-278A-0000-000600600000")
IInArchive : IUnknown
{
	virtual HRESULT STDMETHODCALLTYPE Open(IInStream *, CONST UINT64 *, IArchiveOpenCallback *) PURE;
	virtual HRESULT STDMETHODCALLTYPE Close() PURE;
	virtual HRESULT STDMETHODCALLTYPE GetNumberOfItems(PUINT32) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetProperty(UINT32, PROPID, LPPROPVARIANT) PURE;
	virtual HRESULT STDMETHODCALLTYPE Extract(CONST UINT32 *, UINT32, INT32, IArchiveExtractCallback *) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetArchiveProperty(PROPID, LPPROPVARIANT) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetNumberOfProperties(PUINT32) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(UINT32, LPBSTR, PROPID *, VARTYPE *) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetNumberOfArchiveProperties(PUINT32) PURE;
	virtual HRESULT STDMETHODCALLTYPE GetArchivePropertyInfo(UINT32, LPBSTR, PROPID *, VARTYPE *) PURE;
};

}
